//
//  NNEnvBaseController.m
//  MockQR
//
//  Created by fangshufeng on 2018/3/5.
//  Copyright © 2018年 fangshufeng. All rights reserved.
//

#import "NNEnvBaseController.h"

#define __NN_IS_iPhoneX ([UIScreen mainScreen].bounds.size.width == 375 && [UIScreen mainScreen].bounds.size.height == 812)
@interface NNEnvBaseController ()

@property (nonatomic, strong) UIView *navBarBottomLine;

@end

@implementation NNEnvBaseController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBar.hidden = YES;
    
    
    UIView *cusNavView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,KNNENvWidth , K_MOCK_NAV_Real_Height())];
    cusNavView.backgroundColor = [UIColor whiteColor];
    
    UINavigationBar *customNavBar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, K_MOCK_NAV_Real_Height() - 44, KNNENvWidth, 44)];
    customNavBar.barTintColor = [UIColor whiteColor];
    [customNavBar setBackgroundImage:[[UIImage alloc] init]
                      forBarPosition:UIBarPositionAny
                          barMetrics:UIBarMetricsDefault];
    customNavBar.shadowImage = [[UIImage alloc] init];
    customNavBar.translucent = NO;
    customNavBar.barStyle=  UIBarStyleBlack;
    NSDictionary *attributes= @{
                                NSFontAttributeName:[UIFont boldSystemFontOfSize:17],
                                NSForegroundColorAttributeName:KNNENv_rgba(51, 51, 51, 1),
                                };
    [customNavBar setTitleTextAttributes:attributes];
    
    [customNavBar pushNavigationItem:self.customNavItem animated:NO];
    [cusNavView addSubview:customNavBar];
    
    [cusNavView addSubview:self.navBarBottomLine];
    
    [self.view addSubview:cusNavView];
}

- (void)setTitle:(NSString *)title {
    self.customNavItem.title = title;
}

- (NSString *)title {
    return self.customNavItem.title;
}

- (UINavigationItem *)customNavItem {
    if (!_customNavItem) {
        _customNavItem = [[UINavigationItem alloc]init];
    }
    return _customNavItem;
}

- (UIView *)navBarBottomLine {
    if (!_navBarBottomLine) {
        _navBarBottomLine = [[UIView alloc]initWithFrame:CGRectMake(0,K_MOCK_NAV_Real_Height() - 0.5, KNNENvWidth, 0.5)];
        _navBarBottomLine.backgroundColor = KNNENv_rgba(245, 245, 245, 1);
    }
    return _navBarBottomLine;
}

@end

